﻿//-----------------------------------------------------------------------
// <copyright file="Copyright.cs" author="Michael Herndon">
//     Copyright (c) Michael Herndon.  All rights reserved.
// </copyright>
//-----------------------------------------------------------------------

namespace Amplify.Twitter
{
	using System;
	using System.Collections.Generic;
	using System.Linq;
	using System.ServiceModel.Security;
	using System.Text;

	/// <summary>
	/// Manages fuctionality for creating and deleting blocks against users.  
	/// </summary>
	public class BlockClient : TwitterClient<IBlockClient>, IBlockClient 
	{


		/// <summary>
		/// Initializes a new instance of the <see cref="BlockClient"/> class.
		/// </summary>
		/// <param name="username">The username.</param>
		/// <param name="password">The password.</param>
		public BlockClient(string username, string password)
			:base(username, password)
		{
			
		}

		#region IBlockClient Members


		/// <summary>
		/// Creates a block against a user.
		/// </summary>
		/// <param name="id">The screen name or id of the user.</param>
		/// <returns>returns a <see cref="Amplify.Twitter.User"/> object if the destroy was successful, otherwise false.</returns>
		/// <exception cref="System.ServiceModel.Security.MessageSecurityException" />
		/// <exception cref="Amplify.Twitter.TwitterException"> Throws when a twitter error occurs. </exception>
		public User Create(string id)
		{
			try
			{
				return this.Proxy.Create(id);
			}
			catch (MessageSecurityException securityException)
			{
				this.Rescue(securityException);
			}
			return null;
		}


		/// <summary>
		/// Destroys the block against a user.
		/// </summary>
		/// <param name="id">The screen name or id of the user.</param>
		/// <returns> returns a <see cref="Amplify.Twitter.User"/> object if the destroy was successful, otherwise false. </returns>
		/// <exception cref="System.ServiceModel.Security.MessageSecurityException" />
		/// <exception cref="Amplify.Twitter.TwitterException"> Throws when a twitter error occurs. </exception>
		public User Destroy(string id)
		{
			try 
			{
				return this.Proxy.Create(id);
			}
			catch (MessageSecurityException securityException)
			{
				this.Rescue(securityException);
			}
			return null;
		}

		#endregion
	}
}
